function testPrint(flag, pix) {
    if (flag) {
        console.log(pix, " 测试成功...")
    } else {
        console.log(pix, " 测试失败...")
    }
}

function arrayStackTestPushCase() {
    let as = new ArrayStack();
    as.push('A');
    as.push('B');
    as.push('C');
    let arr = as.toArray();
    let ex = ['A', 'B', 'C'];
    let result = eqArray(ex, arr)
    testPrint(result, "arrayStackTestPushCase")
}

arrayStackTestPushCase();

function arrayStackTestPopCase() {
    let as = new ArrayStack();
    as.push('A');
    as.push('B');
    as.push('C');
    let v = as.pop();
    let result = v == 'C'
    testPrint(result, "arrayStackTestPopCase")

    let ex = ['A','B'];
    let arr = as.toArray();
    result = eqArray(ex, arr)
    testPrint(result, "arrayStackTestPopCase")

    v = as.pop();
    result = v == 'B'
    testPrint(result, "arrayStackTestPopCase")

    ex = ['A'];
    arr = as.toArray();
    result = eqArray(ex, arr)
    testPrint(result, "arrayStackTestPopCase")

    v = as.pop();
    try {
        v = as.pop();
    } catch (e) {
        result = eqStr(e.message, '超出栈范围')
        testPrint(result, "arrayStackTestPopCase")
    }

}

arrayStackTestPopCase();


function arrayStackTestPeekCase() {
    let as = new ArrayStack();
    as.push('A');
    as.push('B');
    as.push('C');
    let v = as.peek();
    let result = v == 'C'
    testPrint(result, "arrayStackTestPeekCase")

    let ex = ['A','B','C'];
    let arr = as.toArray();
    result = eqArray(ex, arr)
    testPrint(result, "arrayStackTestPeekCase")

    v = as.peek();
    result = v == 'C'
    testPrint(result, "arrayStackTestPeekCase")

    arr = as.toArray();
    result = eqArray(ex, arr)
    testPrint(result, "arrayStackTestPeekCase")
}

arrayStackTestPeekCase();


function linkedStackTestPushCase() {
    let ls = new LinkedStack();
    ls.push('A');
    ls.push('B');
    ls.push('C');
    let arr = ls.toArray();
    let ex = ['A', 'B', 'C'];
    let result = eqArray(ex, arr)
    testPrint(result, "linkedStackTestPushCase")
}

linkedStackTestPushCase();


function linkedStackTestPopCase() {
    let ls = new LinkedStack();
    ls.push('A');
    ls.push('B');
    ls.push('C');
    let v = ls.pop();
    let result = v == 'C'
    testPrint(result, "linkedStackTestPopCase")

    let ex = ['A','B'];
    let arr = ls.toArray();
    result = eqArray(ex, arr)
    testPrint(result, "linkedStackTestPopCase")

    v = ls.pop();
    result = v == 'B'
    testPrint(result, "linkedStackTestPopCase")

    ex = ['A'];
    arr = ls.toArray();
    result = eqArray(ex, arr)
    testPrint(result, "linkedStackTestPopCase")

    v = ls.pop();
    try {
        v = ls.pop();
    } catch (e) {
        result = eqStr(e.message, '超出栈范围')
        testPrint(result, "linkedStackTestPopCase")
    }

}

linkedStackTestPopCase();


function linkedStackTestPeekCase() {
    let ls = new LinkedStack();
    ls.push('A');
    ls.push('B');
    ls.push('C');
    let v = ls.peek();
    let result = v == 'C'
    testPrint(result, "linkedStackTestPeekCase")

    let ex = ['A','B','C'];
    let arr = ls.toArray();
    result = eqArray(ex, arr)
    testPrint(result, "linkedStackTestPeekCase")

    v = ls.peek();
    result = v == 'C'
    testPrint(result, "linkedStackTestPeekCase")

    arr = ls.toArray();
    result = eqArray(ex, arr)
    testPrint(result, "linkedStackTestPeekCase")
}

linkedStackTestPeekCase();